package com.bdqn.ch03.proxy;

import org.apache.log4j.Logger;

import java.lang.reflect.Method;

public class InvocationHandler implements java.lang.reflect.InvocationHandler {

    private Logger logger =  Logger.getLogger(IntermediaryImpl.class);

    private Object target;

    public void setTarget(Object target) {
        this.target = target;
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        before();
        Object feedback = method.invoke(target, args);
        after();
        return "看房记录：反馈："+feedback;
    }
    public void before(){
        logger.debug("前期准备");
        logger.debug("查找房子");
        logger.debug("沟通时间");
    }

    public void after(){
        logger.debug("后期处理");
        logger.debug("沟通意见");
    }
}
